/*
 * Copyright (c) 2006-2024, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-03-15     Weihui    first version
 */
#include "Bsp/bsp.h"
#include <fal.h>
#include <App/Bldc_Motor.h>

#include <Bsp/bsp_i2c1.h>
#include <Bsp/bsp_uart4.h>
#include <Bsp/bsp_uart4_dma.h>
#include <Bsp/bsp_svpwm.h>
#include <Bsp/bsp_adc.h>
#include <Bsp/bsp_crc.h>



#include <Pid/pid.h>

#include <IMU/Imu.h>
#include <Magnetic/magnetic.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

/************/
//uart2  调试口
//uart4  imu


#define sys_led_pin GET_PIN(D,2)


int main(void)
{
    int count = 1;
//    fal_init();
//    bsp_adc_init();
    bsp_crc_init();
////
    PID_Init();

    uart_dma_sample();
    imu_init();

    Motor_control_thread_init();
    svpwm_init();

    rt_pin_mode(sys_led_pin, PIN_MODE_OUTPUT);
    while (count++)
    {
        rt_pin_write(sys_led_pin, count%2);
//        LOG_D("Hello RT-Thread!");
        rt_thread_mdelay(500);
    }

    return RT_EOK;
}
